//
//  HZGoodsCategoryColCell.m
//  app
//
//  Created by 刘华舟 on 15/5/21.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZGoodsCategoryColCell.h"

#import "UIImageView+URL.h"

#import "UIImageView+Conveniently.h"

#import "HZFindCategoryColCellModel.h"



@interface HZGoodsCategoryColCell()

@property (strong, nonatomic) HZFindCategoryColCellModel *model;

@property (strong, nonatomic) UIImageView *categoryImgView;
@property (strong, nonatomic) UILabel *categoryTitleLabel;

@end

@implementation HZGoodsCategoryColCell

+ (instancetype)cellWithCollectionView:(HZCollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath{
    NSString *cellReuseIdentifier = @"HZGoodsCategoryColCell";
    HZGoodsCategoryColCell * cell= (HZGoodsCategoryColCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellReuseIdentifier forIndexPath:indexPath];
    if (cell == nil) {
        NSLog(@"创建HZGoodsCategoryColCell失败");
    }
    return cell;
}

- (instancetype)initWithFrame:(CGRect)frame{
    frame = CGRectOf([self.ubo fx:UB_LEFT fy:UB_TOP], [self.ubo uw:kGoodsCategoryColCellWidth uh:kGoodsCategoryColCellHeight]);
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = HZ_MALL_M_LIGHT_GRAY_BACKGROUND_COLOR;
        //图片
        self.categoryImgView = [[UIImageView alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT ux:kGoodsCategoryColCellWidth*0.05f fy:UB_TOP uy:kGoodsCategoryColCellWidth*0.05f],
                                                                        [self.ubo uw:kGoodsCategoryColCellWidth*0.9f uh:kGoodsCategoryColCellWidth*0.9f])];
        self.categoryImgView.backgroundColor = HZ_MALL_M_LIGHT_GRAY_BACKGROUND_COLOR;
        [self addSubview:self.categoryImgView];
        
        //标题
        self.categoryTitleLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT ux:-kGoodsCategoryColCellMargin uy:kGoodsCategoryColCellWidth],
                                                                          [self.ubo fw:UB_WIDTH uw:2*kGoodsCategoryColCellMargin uh:kGoodsCategoryColLabelHeight])];
        self.categoryTitleLabel.backgroundColor = HZ_CLEAR_COLOR;
        [self.categoryTitleLabel setTextColor:HZ_MALL_TEXT_L_LIGHTGRAY_COLOR];
        self.categoryTitleLabel.textAlignment = NSTextAlignmentCenter;
        [self.categoryTitleLabel setFont:kHZFont_Content_S];
        [self addSubview:self.categoryTitleLabel];
        
    }
    return self;
}

- (void)displayWith:(HZFindCategoryColCellModel *)data{
    
    _model = data;
    
    //[self.categoryImgView setImageWithURL:data.categoryPic];
    
    //图像的动画特效
    [self.categoryImgView setFadeOutImageURL:data.pic placehoderImage:nil duration:0.5];

    
    self.categoryTitleLabel.text = data.name;
    
}

@end
